package com.sl.au.service.impl;

import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.EXDEHostToAccountStatistics;
import com.sl.au.repository.EXDEPaidPartsRepairsRepository;
import com.sl.au.service.EXDEPaidPartsRepairsService;

@Service(value="EXDEPaidPartsRepairs")
@Transactional
public class EXDEPaidPartsRepairsServiceImpl extends BaseServiceImpl implements EXDEPaidPartsRepairsService {

	@Autowired
	EXDEPaidPartsRepairsRepository exdePaidPartsRepairsRepository;

	@PersistenceContext
	private EntityManager em;
	
	@Override
	public EXDEPaidPartsRepairsRepository getRepository() {
		// TODO Auto-generated method stub
		return this.exdePaidPartsRepairsRepository;
	}

	/**
	 * 调用片区-备件到款统计的存储过程
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<EXDEHostToAccountStatistics> getMyPage(Map<String, String> condition) {
		List<EXDEHostToAccountStatistics> pages=null;
		//System.out.println(condition.get("beginPaidDate")+","+condition.get("endPaidDate")+","+condition.get("type"));
		Query query = this.em.createNativeQuery("{call HostToAccountStatistics(?,?,?,?)}",EXDEHostToAccountStatistics.class);
		query.setParameter(1, condition.get("beginPaidDate"));
		query.setParameter(2, condition.get("endPaidDate"));
		query.setParameter(3, condition.get("type"));
		query.setParameter(4, condition.get("sSuperior"));
		pages = query.getResultList();
		return pages;
	}

}
